/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz;

import java.io.Serializable;
import javax.swing.*;
import negocio.ui.uiClinica;

/**
 *
 * @author David
 */
public class clienteFrame extends javax.swing.JFrame implements Serializable{

    /**
     * Creates new form clienteFrame
     */
    
    
    uiClinica ui = uiClinica.getInstance();
    public clienteFrame() {
        initComponents();
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jRadioButtonMenuItem1 = new javax.swing.JRadioButtonMenuItem();
        main_panel_clientes = new javax.swing.JPanel();
        label_titulo_cliente = new javax.swing.JLabel();
        sep_cliente = new javax.swing.JSeparator();
        btn_agregar_cliente = new javax.swing.JButton();
        scroll_lista_cliente = new javax.swing.JScrollPane();
        list_cliente = new javax.swing.JList();
        btn_modificar_cliente = new javax.swing.JButton();
        btn_eliminar_cliente = new javax.swing.JButton();
        scroll_txt_info_cliente = new javax.swing.JScrollPane();
        txt_info_cliente = new javax.swing.JTextArea();
        label_informacion_cliente = new javax.swing.JLabel();
        txt_buscar_cliente = new javax.swing.JTextField();
        label_buscar_cliente = new javax.swing.JLabel();
        menu_cliente_menu_bar = new javax.swing.JMenuBar();
        menu_item_Archivo = new javax.swing.JMenu();
        menu_item_cerrar = new javax.swing.JMenuItem();

        jRadioButtonMenuItem1.setSelected(true);
        jRadioButtonMenuItem1.setText("jRadioButtonMenuItem1");

        setTitle("Clientes");
        setBackground(new java.awt.Color(255, 255, 255));
        setMaximumSize(new java.awt.Dimension(850, 600));
        setMinimumSize(new java.awt.Dimension(850, 600));
        setPreferredSize(new java.awt.Dimension(450, 600));
        setResizable(false);

        main_panel_clientes.setBackground(new java.awt.Color(255, 255, 255));
        main_panel_clientes.setMaximumSize(new java.awt.Dimension(850, 650));
        main_panel_clientes.setMinimumSize(new java.awt.Dimension(850, 650));
        main_panel_clientes.setPreferredSize(new java.awt.Dimension(850, 600));

        label_titulo_cliente.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
        label_titulo_cliente.setText("Clientes");

        btn_agregar_cliente.setText("Agregar Clientes");
        btn_agregar_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_agregar_clienteActionPerformed(evt);
            }
        });

        list_cliente.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        list_cliente.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        list_cliente.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                list_clienteValueChanged(evt);
            }
        });
        scroll_lista_cliente.setViewportView(list_cliente);

        btn_modificar_cliente.setText("Modificar Clientes");
        btn_modificar_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_modificar_clienteActionPerformed(evt);
            }
        });

        btn_eliminar_cliente.setText("Eliminar Cliente");
        btn_eliminar_cliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_eliminar_clienteActionPerformed(evt);
            }
        });

        txt_info_cliente.setColumns(20);
        txt_info_cliente.setRows(5);
        scroll_txt_info_cliente.setViewportView(txt_info_cliente);

        label_informacion_cliente.setText("Informacion del Cliente");

        txt_buscar_cliente.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txt_buscar_clienteKeyReleased(evt);
            }
        });

        label_buscar_cliente.setText("Buscar Cliente (nombre, apellidos):");

        javax.swing.GroupLayout main_panel_clientesLayout = new javax.swing.GroupLayout(main_panel_clientes);
        main_panel_clientes.setLayout(main_panel_clientesLayout);
        main_panel_clientesLayout.setHorizontalGroup(
            main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(main_panel_clientesLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(label_titulo_cliente)
                    .addComponent(sep_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 830, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(main_panel_clientesLayout.createSequentialGroup()
                        .addComponent(btn_agregar_cliente)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_modificar_cliente)
                        .addGap(6, 6, 6)
                        .addComponent(btn_eliminar_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(main_panel_clientesLayout.createSequentialGroup()
                        .addComponent(scroll_lista_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 405, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addGroup(main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_buscar_cliente)
                            .addComponent(txt_buscar_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(label_informacion_cliente)
                            .addComponent(scroll_txt_info_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE)))))
        );
        main_panel_clientesLayout.setVerticalGroup(
            main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(main_panel_clientesLayout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(label_titulo_cliente)
                .addGap(6, 6, 6)
                .addComponent(sep_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addGroup(main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btn_modificar_cliente)
                        .addComponent(btn_agregar_cliente))
                    .addComponent(btn_eliminar_cliente))
                .addGap(10, 10, 10)
                .addGroup(main_panel_clientesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(scroll_lista_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 468, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(main_panel_clientesLayout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(label_buscar_cliente)
                        .addGap(6, 6, 6)
                        .addComponent(txt_buscar_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(label_informacion_cliente)
                        .addGap(6, 6, 6)
                        .addComponent(scroll_txt_info_cliente, javax.swing.GroupLayout.PREFERRED_SIZE, 393, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );

        menu_item_Archivo.setText("Archivo");

        menu_item_cerrar.setText("Cerrar");
        menu_item_cerrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menu_item_cerrarActionPerformed(evt);
            }
        });
        menu_item_Archivo.add(menu_item_cerrar);

        menu_cliente_menu_bar.add(menu_item_Archivo);

        setJMenuBar(menu_cliente_menu_bar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(main_panel_clientes, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(main_panel_clientes, javax.swing.GroupLayout.PREFERRED_SIZE, 585, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_agregar_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_agregar_clienteActionPerformed
        ui.resetNuevoClienteFrame();
        ui.getNuevoClienteF().setVisible(true);
    }//GEN-LAST:event_btn_agregar_clienteActionPerformed

    private void btn_modificar_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_modificar_clienteActionPerformed
        ui.modificar_cliente_frame(this);
    }//GEN-LAST:event_btn_modificar_clienteActionPerformed

    private void btn_eliminar_clienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_eliminar_clienteActionPerformed
        ui.eliminar_cliente(this);
    }//GEN-LAST:event_btn_eliminar_clienteActionPerformed

    private void menu_item_cerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menu_item_cerrarActionPerformed
        this.setVisible(false);
    }//GEN-LAST:event_menu_item_cerrarActionPerformed

    private void txt_buscar_clienteKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txt_buscar_clienteKeyReleased
        ui.buscarClientes(this);
    }//GEN-LAST:event_txt_buscar_clienteKeyReleased

    private void list_clienteValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_list_clienteValueChanged
        ui.buscarInfoCliente(this);       
    }//GEN-LAST:event_list_clienteValueChanged

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(clienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(clienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(clienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(clienteFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new clienteFrame().setVisible(true);
            }
        });
    }

    public JButton getBtn_agregar_cliente() {
        return btn_agregar_cliente;
    }

    public JButton getBtn_eliminar_cliente() {
        return btn_eliminar_cliente;
    }

    public JButton getBtn_modificar_cliente() {
        return btn_modificar_cliente;
    }

    public JLabel getLabel_titulo_cliente() {
        return label_titulo_cliente;
    }

    public JList getList_cliente() {
        return list_cliente;
    }

    public JPanel getMain_panel_clientes() {
        return main_panel_clientes;
    }

    public JScrollPane getScroll_lista_cliente() {
        return scroll_lista_cliente;
    }

    public JSeparator getSep_cliente() {
        return sep_cliente;
    }

    public uiClinica getUi() {
        return ui;
    }

    public JLabel getLabel_buscar_cliente() {
        return label_buscar_cliente;
    }

    public void setLabel_buscar_cliente(JLabel label_buscar_cliente) {
        this.label_buscar_cliente = label_buscar_cliente;
    }

    public JLabel getLabel_informacion_cliente() {
        return label_informacion_cliente;
    }

    public void setLabel_informacion_cliente(JLabel label_informacion_cliente) {
        this.label_informacion_cliente = label_informacion_cliente;
    }

    public JMenuBar getMenu_cliente_menu_bar() {
        return menu_cliente_menu_bar;
    }

    public void setMenu_cliente_menu_bar(JMenuBar menu_cliente_menu_bar) {
        this.menu_cliente_menu_bar = menu_cliente_menu_bar;
    }

    public JMenu getMenu_item_Archivo() {
        return menu_item_Archivo;
    }

    public void setMenu_item_Archivo(JMenu menu_item_Archivo) {
        this.menu_item_Archivo = menu_item_Archivo;
    }

    public JMenuItem getMenu_item_cerrar() {
        return menu_item_cerrar;
    }

    public void setMenu_item_cerrar(JMenuItem menu_item_cerrar) {
        this.menu_item_cerrar = menu_item_cerrar;
    }  

    public JScrollPane getScroll_txt_info_cliente() {
        return scroll_txt_info_cliente;
    }

    public void setScroll_txt_info_cliente(JScrollPane scroll_txt_info_cliente) {
        this.scroll_txt_info_cliente = scroll_txt_info_cliente;
    } 

    public JTextField getTxt_buscar_cliente() {
        return txt_buscar_cliente;
    }

    public void setTxt_buscar_cliente(JTextField txt_buscar_cliente) {
        this.txt_buscar_cliente = txt_buscar_cliente;
    }

    public JTextArea getTxt_info_cliente() {
        return txt_info_cliente;
    }

    public void setTxt_info_cliente(JTextArea txt_info_cliente) {
        this.txt_info_cliente = txt_info_cliente;
    }
    
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_agregar_cliente;
    private javax.swing.JButton btn_eliminar_cliente;
    private javax.swing.JButton btn_modificar_cliente;
    private javax.swing.JRadioButtonMenuItem jRadioButtonMenuItem1;
    private javax.swing.JLabel label_buscar_cliente;
    private javax.swing.JLabel label_informacion_cliente;
    private javax.swing.JLabel label_titulo_cliente;
    private javax.swing.JList list_cliente;
    private javax.swing.JPanel main_panel_clientes;
    private javax.swing.JMenuBar menu_cliente_menu_bar;
    private javax.swing.JMenu menu_item_Archivo;
    private javax.swing.JMenuItem menu_item_cerrar;
    private javax.swing.JScrollPane scroll_lista_cliente;
    private javax.swing.JScrollPane scroll_txt_info_cliente;
    private javax.swing.JSeparator sep_cliente;
    private javax.swing.JTextField txt_buscar_cliente;
    private javax.swing.JTextArea txt_info_cliente;
    // End of variables declaration//GEN-END:variables
}
